home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmigaPlus / Tools / Anwendungen / CManager / Developer / Demos / CMURL.c next >
Encoding:
C/C++ Source or Header  |  2004-01-31  |  5.4 KB  |  173 lines

  1.  
  2. #define __USE_SYSBASE
  3. #include <proto/exec.h>
  4. #include <proto/intuition.h>
  5. #include <proto/dos.h>
  6. #include <proto/muimaster.h>
  7.  
  8. #include <libraries/mui.h>
  9. #include <libraries/CManager.h>
  10. #include <utility/hooks.h>
  11.  
  12. #include <clib/alib_protos.h>
  13.  
  14. #include <mui/textinput_mcc.h>
  15. #include <mui/CManager_mcc.h>
  16.  
  17. #include <stdio.h>
  18. #include <string.h>
  19.  
  20. /***************************************************************************/
  21.  
  22. #define SAVEDS __saveds
  23. #define ASM __asm
  24. #define STDARGS __stdargs
  25. #define REG(x) register __ ## x
  26. #define MAKE_ID(a,b,c,d) ((ULONG)(a)<<24|(ULONG)(b)<<16|(ULONG)(c)<<8|(ULONG)(d))
  27.  
  28. /***************************************************************************/
  29.  
  30. struct data
  31. {
  32.     Object *pop;        /* The Popobject in itself            */
  33.     Object *popString;  /* The String object of the Popobject */
  34.     ULONG  dataLoad;    /* Flag, if 0 load data in CManager   */
  35. };
  36.  
  37. /***************************************************************************/
  38.  
  39. long           __stack = 64000;
  40. struct Library *MUIMasterBase;
  41.  
  42. /***********************************************************************/
  43. /*
  44. ** We just check if data are to be load in CManager
  45. */
  46.  
  47. ULONG ASM SAVEDS
  48. strObjFun(REG(a0) struct Hook *hook,REG(a1) Object *popString,REG(a2) Object *popObject)
  49. {
  50.     register struct data *data = hook->h_Data;
  51.  
  52.     if (!data->dataLoad)
  53.     {
  54.         DoMethod(popObject,MUIM_CManager_LoadData,NULL,NULL);
  55.         data->dataLoad = 1;
  56.     }
  57.  
  58.     return TRUE;
  59. }
  60.  
  61. /***************************************************************************/
  62. /*
  63. ** Set the string contents and close the pop
  64. */
  65.  
  66. ULONG SAVEDS ASM
  67. appDoubleClickFun(REG(a0) struct Hook *hook,REG(a1) struct CMWWW *entry,REG(a2) Object *cm)
  68. {
  69.     register struct data *data = hook->h_Data;
  70.     register STRPTR      s;
  71.  
  72.     switch (entry->Type)
  73.     {
  74.         case CME_WWW:
  75.             s = entry->WWW;
  76.             break;
  77.  
  78.         case CME_FTP:
  79.             s = ((struct CMFTP *)entry)->FTP;
  80.     }
  81.  
  82.     set(data->popString,MUIA_Textinput_Contents,s);
  83.     DoMethod(data->pop,MUIM_Popstring_Close,TRUE);
  84.  
  85.     return 0;
  86. }
  87.  
  88. /***************************************************************************/
  89.  
  90. int
  91. main(int argc,char **argv)
  92. {
  93.     register int res = RETURN_ERROR;
  94.  
  95.     if (MUIMasterBase = OpenLibrary("muimaster.library",19))
  96.     {
  97.         struct data data;
  98.         struct Hook strObjHook, appDoubleClickHook;
  99.         Object      *app, *win, *cm;
  100.  
  101.         if (app = ApplicationObject,
  102.                 MUIA_Application_Title,       "CMURL",
  103.                 MUIA_Application_Version,     "$VER: CMURL 1.1 (18.3.2003)",
  104.                 MUIA_Application_Copyright,   "Copyright 2003 by Alfonso Ranieri",
  105.                 MUIA_Application_Author,      "Alfonso Ranieri <alforan@tin.it>",
  106.                 MUIA_Application_Description, "CManager.mcc example",
  107.                 MUIA_Application_Base,        "CMURL",
  108.  
  109.                 SubWindow, win = WindowObject,
  110.                     MUIA_Window_ID,    MAKE_ID('M','A','I','N'),
  111.                     MUIA_Window_Title, "CMURL",
  112.  
  113.                     WindowContents, VGroup,
  114.                         Child, HGroup,
  115.                             Child, Label1("_URL"),
  116.                             Child, data.pop = PopobjectObject,
  117.                               MUIA_Popobject_StrObjHook, &strObjHook,
  118.                                 MUIA_Popstring_String, data.popString = TextinputObject,
  119.                                     StringFrame,
  120.                                     MUIA_Textinput_MaxLen, 256,
  121.                                     MUIA_ControlChar,      'u',
  122.                                 End,
  123.                                 MUIA_Popstring_Button, PopButton(MUII_PopUp),
  124.                                 MUIA_Popobject_Object, cm = CManagerObject,
  125.                                     MUIA_Frame,                   MUIV_Frame_InputList,
  126.                                     MUIA_CManager_AppDoubleClick, &appDoubleClickHook,
  127.                                     MUIA_CManager_HideUsers,      TRUE,
  128.                                     MUIA_CManager_HideChat,       TRUE,
  129.                                     MUIA_CManager_HideTelnet,     TRUE,
  130.                                     MUIA_CManager_NoMenu,         TRUE,
  131.                                 End,
  132.                             End,
  133.                         End,
  134.                     End,
  135.                 End,
  136.             End)
  137.         {
  138.             ULONG       signals;
  139.  
  140.             data.dataLoad = 0;
  141.  
  142.             strObjHook.h_Entry = (HOOKFUNC)strObjFun;
  143.             strObjHook.h_Data  = &data;
  144.  
  145.             appDoubleClickHook.h_Entry = (HOOKFUNC)appDoubleClickFun;
  146.             appDoubleClickHook.h_Data  = &data;
  147.  
  148.             DoMethod(win,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,MUIV_Notify_Application,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  149.  
  150.             set(win,MUIA_Window_Open,TRUE);
  151.  
  152.             for (signals = 0; DoMethod(app,MUIM_Application_NewInput,&signals)!=MUIV_Application_ReturnID_Quit; )
  153.                 if (signals && ((signals = Wait(signals | SIGBREAKF_CTRL_C)) & SIGBREAKF_CTRL_C)) break;
  154.  
  155.             MUI_DisposeObject(app);
  156.  
  157.             res = RETURN_OK;
  158.         }
  159.         else
  160.         {
  161.             Printf("%s: can't create application\n",argv[0]);
  162.             res = RETURN_FAIL;
  163.         }
  164.  
  165.         CloseLibrary(MUIMasterBase);
  166.     }
  167.     else Printf("%s: Can't open muimaster.library ver 19 or higher\n",argv[0]);
  168.  
  169.     return res;
  170. }
  171.  
  172. /***********************************************************************/
  173.